#ifndef VSSCENE_H
#define VSSCENE_H
#include "VSNode.h"
namespace VSEngine2
{
	class VSRenderer;
	class VSStream;
	class VSQuadNode : public VSNode
	{
		enum
		{
			MAX_NUM = 5
		};
	public:
		bool RecursiveBuild(const VSArray<VSSpatial *> &pObjectArray);

	};
	typedef VSPointer<VSQuadNode> VSQuadNodePtr;
	
	class VSGRAPHIC_API VSScene:public VSObject
	{
		//PRIORITY
		
		//RTTI
		DECLARE_RTTI;
		DECLARE_INITIAL
	public:
		friend class VSSceneManager;
		void Update(double dAppTime);
		void CollectUpdateInfo();
		VSScene();
		~VSScene();

		inline void AddCamera(VSCamera * pCamera);
		inline VSCamera * GetCamera(unsigned int i)const;
		inline void ClearCamera();
		inline void DeleteCamera(unsigned int i);
		inline void DeleteCamera(VSCamera * pCamera);
		inline unsigned int GetCameraNum() const;
		
		inline void AddLight(VSLight * pLight);
		inline VSLight * GetLight(unsigned int i)const;
		inline void ClearLight();
		inline void DeleteLight(unsigned int i);
		inline void DeleteLight(VSLight * pLight);
		inline unsigned int GetLightNum()const;
		inline VSLight * GetAllLight(unsigned int i)const;
		inline unsigned int GetAllLightNum()const;


		virtual void AddObject(VSSpatial * pObject);
		virtual void DeleteObject(VSSpatial *pObject);
		virtual void DeleteAllObject();	

		virtual void ComputeVisibleSet(VSCuller & Culler,bool bNoCull,double dAppTime);
		bool Build();
	protected:
		VSArray<VSLight *> m_pAllLight;
		VSArray<VSCamera *> m_pAllCamera;

		VSArray<VSLightPtr> m_pLight;
		VSArray<VSCameraPtr> m_pCamera;

		VSArray<VSSpatialPtr> m_pDynamic;
		VSQuadNodePtr m_pStaticRoot;

	};
	#include "VSScene.inl"
	DECLARE_Ptr(VSScene);
	VSTYPE_MARCO(VSScene);
}
#endif